import request from '@/utils/axios/axios-service.ts'

export const getMenuList = (params: any) =>request.get('/v1/menu', {params:params})
export  const getMenuUpdate=(data:any,params:any)=>request.put('/v1/menu',data,{params:params})
export  const getMenuAdd=(data:any,params:any)=>request.post('/v1/menu',data,{params:params})
export const getMenuDelete=(params:any)=>request.delete('/v1/menu',{params:params})
export const getMenuInfo=(params:any)=>request.get('/v1/menu',{params:params})
//角色
export const sysRoleList = (params: any) => request.get('/v1/role', {params: params})
export const sysRoleAdd = (data: any,params:any) => request.post('/v1/role', data, {params:params})
export  const sysRoleUpdate = (data: any,params:any) => request.put('/v1/role', data, {params:params})
export const sysRoleDelete = (params: any) => request.delete('/v1/role', {params:params})
//账号管理
export const sysUserList = (params: any) => request.get('/v1/client', {params: params})
export const sysUserAdd = (data: any,params:any) => request.post('/v1/client', data, {params:params})
export  const sysUserUpdate = (data: any,params:any) => request.put('/v1/client', data, {params:params})
export const sysUserDelete = (params: any) => request.delete('/v1/client', {params:params})
export const sysUserInfo = (params: any) => request.get('/v1/client',{params:params})
/**
 * 图片上传接口
 */
export const sysOssTokenInfo = (params:any) => request.get('/v1/oss',{params:params})
export const sysOssConfig = () => request.get('/sys/oss/config')
export const sysOssConfigUpdate = (params: any) => request.post('/sys/oss/config', params)
export const sysOssList = (params: any) => request.get('/sys/oss/list', {params: params})

/**
 * 管理员接口
 */


export const sysUserSaveOrUpdate = (params: any, isCreate: boolean) => request.post(isCreate ? '/sys/user/create' : '/sys/user/update', params)
// export const sysUserDelete = (ids: number[]) => request.post('/sys/user/delete', ids)
export const sysUserPasswordModify = (params: any,data:any) => request.put('/v1/client', params,{params:data})
export const sysUserBaseModify = (params: any) => request.post('/sys/user/base_modify', params)

/**
 * 角色接口
 */

export const sysRoleSelect = () => request.get('/sys/role/select')
export const sysRoleInfo = (id: number) => request.get('/sys/role/info/' + id)
export const sysRoleSaveOrUpdate = (params: any, isCreate: boolean) => request.post(isCreate ? '/sys/role/create' : '/sys/role/update', params)
// export const sysRoleDelete = (ids: number[]) => request.post('/sys/role/delete', ids)

/**
 * 菜单接口
 */
export const sysMenuTreeList = (params?: any) => request.get('/sys/menu/treeList', {params: params})
export const sysMenuTreeSelect = () => request.get('/sys/menu/treeSelect')
export const sysMenuSwitchStatus = (id: number) => request.post('/sys/menu/switch_status/' + id)
export const sysMenuInfo = (id: number) => request.get('/sys/menu/info/' + id)
export const sysMenuSaveOrUpdate = (params: any, isCreate: boolean) => request.post(isCreate ? '/sys/menu/create' : '/sys/menu/update', params)
export const sysMenuCleanPermissionsCache = () => request.post('/sys/menu/clean_cache')

/**
 * 配置接口
 */
export const sysConfigList = (params?: any) => request.get('/sys/config/list', {params: params})
export const sysConfigInfo = (id: number) => request.get('/sys/config/info/' + id)
export const sysConfigSaveOrUpdate = (params: any, isCreate: boolean) => request.post(isCreate ? '/sys/config/create' : '/sys/config/update', params)

/**
 * 日志接口
 */
export const sysLoginLogList = (params?: any) => request.get('/sys/login_log/list', {params: params})
export const sysLoginLogDelete = (ids: number[]) => request.post('/sys/login_log/delete', ids)
export const sysOperationLogList = (params?: any) => request.get('/v1/access', {params: params})
export const sysOperationLogDelete = (ids: number[]) => request.post('/sys/operation_log/delete', ids)

/**
 * 字典接口
 */
export const sysDictTypeList = (params: any) => request.get('/sys/dict/list', {params: params})
export const sysDictTypeInfo = (id: number) => request.get('/sys/dict/info/' + id)
export const sysDictTypeSaveOrUpdate = (params: any, isCreate: boolean) => request.post(isCreate ? '/sys/dict/create' : '/sys/dict/update', params)
export const sysDictTypeDelete = (id: number) => request.post('/sys/dict/delete/' + id)
export const sysDictTypeAll = () => request.get('/sys/dict/all')
export const sysDictTypeTree = (params: any) => request.get('/sys/dict/tree', {params: params})

export const sysDictDataList = (params: any) => request.get('/sys/dict/data/list', {params: params})
export const sysDictDataInfo = (id: number) => request.get('/sys/dict/data/info/' + id)
export const sysDictDataSaveOrUpdate = (params: any, isCreate: boolean) => request.post(isCreate ? '/sys/dict/data/create' : '/sys/dict/data/update', params)
export const sysDictDataDelete = (id: number) => request.post('/sys/dict/data/delete/' + id)

export type SysMenuData = {
  id?: number;
  pid?: number;
  title?: string;
  name?: string;
  icon?: string;
  path?: string;
  redirect?: string;
  component?: string;
  permissions?: string;
  type: number;
  hidden?: number;
  cache?: number;
  order_num?: number;
  parent_name?: string;
  status?: number;
  sort:number;
  children?: SysMenuData[];
  plat?:string
}

export type SysRoleData = {
  id?: number;
  mid?: string;
  ip?: string;
  status?:Number;
  type?: Number;
}

export interface SysDictType {
  id: number;
  name: string;
  type: string;
  remark: string;
  enabled: boolean;
}

export interface SysDictTypeTree extends SysDictType {
  parent_id: number;
}

export type SysDictData = {
  id: number;
  dict_type_id?: number;
  dict_label: string;
  dict_value: string;
  css_class: string;
  list_class: string;
  remark: string;
  order_num: number;
  enabled: boolean;
}
